package ogmios.components.templatetags;
import java.io.*;
import ogmios.core.OgmiosUtilities;
import javax.swing.*;
/**
 * A premade tag that requests user input
 */
public class UserInputTag implements TemplateTag
{
 public final String tag;
 public final int numberOfLines;
 public final String question;
 public static final int ONE_LINE = 0;
 public static final int MULTI_LINE = 1;
 /**
 * Creates UserInputTag with {description} as a tag
 */
 public UserInputTag()
 {
  this("{description}");
 }
 /**
 * Creates UserInputTag with "Enter in a description:" as the question
 * @param     tag     The tag that matches with this UserInputTag
 */
 public UserInputTag(String tag)
 {
  this(tag, "Enter in a description:");
 }
 /**
 * Creates UserInputTag with ONE_LINE as the number of lines
 * @param     tag     The tag that matches with this UserInputTag
 * @param     question     The text to display to the user
 */
 public UserInputTag(String tag, String question)
 {
  this(tag, question, ONE_LINE);
 }
 /**
 * Creates UserInputTag
 * @param     tag     The tag that matches with this UserInputTag
 * @param     question     The text to display to the user
 * @param     numberOfLines     Either ONE_LINE or MULTI_LINE
 */
 public UserInputTag(String tag, String question, int numberOfLines)
 {
  this.tag = tag;
  this.question = question;
  this.numberOfLines = numberOfLines;
 }
 public String getTag()
 {
  return tag;
 }

 public String getValue(File outputFile)
 {
  String value = numberOfLines == ONE_LINE ?
    JOptionPane.showInputDialog(null, question, "Template Info") :
    OgmiosUtilities.showMultiLineInputDialog(null, question, "Template Info");
  return value == null ? "" : value;
 }
}
